package slidingpenguins.slideshow.model {

	[Bindable]
	public class Image {
		private var _uri:String;
		private var _isInline:Boolean;
		private var _left:Distance;
		private var _top:Distance;
		private var _width:Distance;
		private var _height:Distance;
		private var _rotation:uint;
		private var _zIndex:uint;

		public function Image(uri:String) {
			_uri = uri;
			_isInline = false;
			_left = new Distance(0);
			_top = new Distance(0);
			_width = new Distance(0, Distance.DISTANCE_UNIT_AUTO);
			_height = new Distance(0, Distance.DISTANCE_UNIT_AUTO);
			_rotation = 0;
			_zIndex = 0;
		}

		public function get uri():String {
			return _uri;
		}
		
		public function set uri(uri:String):void {
			_uri = uri;
		}

		public function get isInline():Boolean {
			return _isInline;
		}
		
		public function get slideshowURI():String {
			if (isInline) {
				return SlideshowFile.SLIDESHOW_INLINE_URI_SCHEMA + uri;
			} else { 
				return uri;
			}
		}

		public function set isInline(value:Boolean):void {
			_isInline = value;
		}

		public function get left():Distance {
			return _left;
		}

		public function set left(value:Distance):void {
			_left = value;
		}

		public function get top():Distance {
			return top;
		}

		public function set top(value:Distance):void {
			_top = value;
		}

		public function get width():Distance {
			return _width;
		}

		public function set width(value:Distance):void {
			if (value.value < 0) {
				throw new ArgumentError();
			}

			_width = value;
		}

		public function get height():Distance {
			return _height;
		}

		public function set height(value:Distance):void {
			if (value.value < 0) {
				throw new ArgumentError();
			}

			_height = value;
		}

		public function get rotation():uint {
			return _rotation;
		}

		public function set rotation(value:uint):void {
			if (value < 0 || value > 359) {
				throw new ArgumentError();
			}

			_rotation = value;
		}

		public function get zIndex():uint {
			return _zIndex;
		}

		public function set zIndex(value:uint):void {
			_zIndex = value;
		}
	}
}
